<template>
	<view>
		<!-- #ifndef  H5 -->
		<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
			<u-navbar :is-back="false" title="团队" :title-bold="true" :is-fixed="false" :border-bottom="false"
				:background="{ background: 'rgba(256,256, 256, 1)' }" title-color="#000"></u-navbar>
		</u-sticky>
		<!-- #endif -->
		<view class="list" v-if="lists.length > 0">
			<view class="item" v-for="(item,index) in lists">
				<view class="number">
					{{item.name}}
				</view>
				<view class="price">
					价格:{{item.goods_lable_name}}
				</view>
				<view class="info">
					<view class="store" v-if="item.dianz[0]">
						<view class="label">{{item.dianz[0].user_type_text}}</view>
						<view class="ident">ID:{{item.dianz[0].user_id}}</view>
					</view>
					<view class="staff" v-if="item.diany">
						<view class="jt" v-for="(itemy,indexy) in item.diany">
							<view class="label">{{itemy.user_type_text}}</view>
							<view class="ident">ID:{{itemy.user_id}}</view>
						</view>
					</view>
				</view>
				<view class="other" v-if="item.dians.length > 0">
					<view class="oth-item" v-for="(items,indexs) in item.dians">
						<view class="ident">ID:{{items.user_id}}</view>
						<view class="ident">荐ID:{{items.parent_id}}</view>
					</view>
				</view>
				<view class="other" v-else>
					<view class="oth-item">
						<view class="ident"></view>
						<view class="ident"></view>
					</view>
					<view class="oth-item">
						<view class="ident"></view>
						<view class="ident"></view>
					</view>
					<view class="oth-item">
						<view class="ident"></view>
						<view class="ident"></view>
					</view>
					<view class="oth-item">
						<view class="ident"></view>
						<view class="ident"></view>
					</view>
				</view>
				<view class="desc">
					*根据贡献值优先成为店长
				</view>
			</view>

		</view>
		<view class="none" v-else>
			<view class="empty">
				<u-empty text="暂无团队" mode="data"></u-empty>
			</view>
		</view>
		<view class="tabbar">
			<tabbar />
		</view>
	</view>
</template>
<script>
	import {
		apiGetTeamLists
	} from '@/api/team'
	export default {
		data() {
			return {
				lists: [],
			};
		},
		onPullDownRefresh(){
			this.listTuan()
		},
		onLoad() {
			this.listTuan()
		},
		methods:{
			listTuan(){
				apiGetTeamLists().then(res => {
					let lists = [];
					for (var i = 0; i < res.length; i++) {
						lists[i] = res[i];
						lists[i].dianz = res[i].user_team.filter(item => item.is_team_leader === 1 && item
							.user_type === 1);
						lists[i].diany = res[i].user_team.filter(item => item.is_team_leader === 1 && item
							.user_type === 2);
						lists[i].dians = res[i].user_team.filter(item => item.is_team_leader === 2 && item
							.user_type === 2);
					}
					this.lists = lists
					uni.stopPullDownRefresh()
				})
			}
		}
	}
</script>

<style lang="scss">
	.list {
		.ident {
			width: 100%;
			font-weight: 300;
		}

		.item {
			width: 700rpx;
			padding: 10rpx;
			margin: 10rpx auto;
			background-image: url('../../static/images/gback.png');
			background-size: cover;
			border-radius: 50rpx;
			background-repeat: no-repeat;

			.number {
				font-size: 40rpx;
				font-weight: bold;
				text-align: right;
				padding: 0 10rpx;
				color: #FFF;
			}

			.price {
				font-size: 40rpx;
				font-weight: bold;
				text-align: center;
				line-height: 60rpx;
				margin-top: 80rpx;
				color: #FFF;
			}

			.info {
				background-image: url('../../static/images/asfgd.png');
				background-size: contain;
				background-repeat: no-repeat;
				color: #FFF;
				width: 580rpx;
				margin: 0 auto;
				margin-top: 20rpx;

				.store {
					text-align: center;
					height: 90rpx;
					display: flex;
					flex-wrap: wrap;
					align-content: center;

					.label {
						font-size: 30rpx;
						width: 100%;
						font-weight: bold;
					}

				}

				.staff {
					display: flex;
					height: 75rpx;
					justify-content: space-between;
					width: 580rpx;
					margin: 0 auto;
					margin-top: 80rpx;
					align-items: center;

					.jt {
						width: 166rpx;
						text-align: center;
					}
				}

			}

			.other {
				display: flex;
				margin-top: 40rpx;
				justify-content: space-between;

				.oth-item {
					color: #f15437;
					background-color: #ffebe2;
					border-radius: 20rpx;
					width: 160rpx;
					height: 130rpx;
					text-align: center;
					display: flex;
					flex-wrap: wrap;
					align-content: center;
					justify-content: center;
				}
			}

			.desc {
				text-align: center;
				font-size: 26rpx;
				line-height: 70rpx;
			}
		}
	}

	.none {
		display: flex;
		height: 90vh;
		justify-content: center;
		align-items: center;
		text-align: center;
		font-size: 42rpx;
	}
</style>